
#ifndef _TOF050F_H
#define _TOF050F_H


#include "stdint.h"

#define TOF_DEVICE_ID_X1        0x01
#define TOF_DEVICE_ID_X2        0x02
#define TOF_DEVICE_ID_X3        0x03
#define TOF_DEVICE_ID_X4        0x04
#define TOF_DEVICE_ID_X5        0x05
#define TOF_DEVICE_ID_X6        0x06

#define TOF_DEVICE_ALL          5

#define MODBUS_CODE_READ_REG    0x03
#define MODBUS_CODE_WRITE_REG   0x06

#define TOF_RANGE_MAX_MM        1800

typedef struct
{
	uint8_t device_ID;
	uint8_t function_code;
	uint8_t length;
	uint8_t *databuf;
	uint8_t CRC_L;
	uint8_t CRC_H;
	
	uint8_t updata_cnt;

}STR_TOF_REG_RETURN;


typedef struct
{
	uint8_t device_ID;
	uint8_t function_code;
	uint8_t reg_addr_H;
	uint8_t reg_addr_L;
	uint8_t data_H;
	uint8_t data_L;
	uint8_t CRC_L;
	uint8_t CRC_H;

}STR_TOF_REG_RW;

extern uint16_t tofrange_mm[TOF_DEVICE_ALL];
extern void tof050f_test(void);
extern void tof050f_modbus_comm(void);

/*!
    \brief      
    \param[in]  none
    \param[out] none
    \retval     none
*/

static inline uint16_t get_tof050f_distance(uint8_t num)
{
	return tofrange_mm[num-1];
}



#endif

